#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n = 0, count = 0;
    int ans = 0;
    cin >> n;
    vector<int> arr1(n), arr2(n);
    for (int i = 0; i < n; i++) cin >> arr1[i];
    for (int i = 0; i < n; i++) cin >> arr2[i];
    for (int i = 0; i < n; i++)
    {
        if (arr1[i] == arr2[i]) count++;
        else count = 0;
        if (count >= 1 && count <= 2) ans += 10;
        else if (count <= 4) ans += 10 * 1.1;
        else if (count <= 8) ans += 10 * 1.2;
        else if (count >= 9) ans += 10 * 1.3;
    }
    cout << ans << endl;
    return 0;
}